package com.aaa.stock.controller.api;


import com.aaa.entity.Medicines;
import com.aaa.entity.Purchase;
import com.aaa.entity.PurchaseItem;
import com.aaa.stock.service.EditPurchaseService;
import com.aaa.stock.vo.EditPurchaseVo;
import com.aaa.stock.vo.MedicinesVo;
import com.aaa.stock.vo.PurchaseDtoVo;
import com.aaa.vo.Result;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;

@RestController
@RequestMapping("stock/api/edit")
public class ApiEditPurchaseController {

    @Autowired
    private EditPurchaseService editPurchaseService;

    //id对照查询
    @PostMapping("getPurchaseItem/{purchaseId}")
    public Result<List<PurchaseItem>> getPurchaseItem( @PathVariable String purchaseId){
        return editPurchaseService.getPurchaseItem(purchaseId);

    }

    //添加弹出层分页查询
    @PostMapping("gettccall/{currentPage}/{pageSize}")
    public Result<IPage<Medicines>> gettccall(
            @PathVariable Integer currentPage,
            @PathVariable Integer pageSize,
            @RequestBody EditPurchaseVo editPurchaseVo
    ){
        return  editPurchaseService.findBytccAll(currentPage,pageSize,editPurchaseVo);
    }

    //雪花生成单号
    @GetMapping("xuehua")
    public Result<String>xuehua(){
        System.out.println(editPurchaseService);
        return editPurchaseService.purchaseIdRequest();
    }

    @PostMapping("getPurchaseSh/{queryid}")
    public Result<List<PurchaseItem>> getPurchaseSh( @PathVariable String queryid){
        System.out.println("-------------------------------------------------"+queryid);
        return editPurchaseService.getPurchaseSh(queryid);
    }

//    @PostMapping("GetAdd")
//    public Result<Boolean> GetAdd(@RequestBody PurchaseDtoVo purchaseVo) {
//
//        Result<Boolean> purchaseDtoVoResult = editPurchaseService.GetAdd(purchaseVo);
//        return purchaseDtoVoResult;
//    }
}
